package algorithm;

public class leetcode_0649 {
    public String predictPartyVictory(String senate) {
        int sum=senate.length();
        char[] list=senate.toCharArray();
        int sum_r=0;
        int sum_d=0;
        for(int i=0;i<sum;++i){
            if('R'==list[i]) sum_r++;
            else sum_d++;
        }
        int r=0;
        int d=0;
        while(sum_r>0&&sum_d>0){
            for(int i=0;i<sum;++i){
                if(list[i]=='R'){
                    if(d>0) {d--;list[i]=' ';sum_r--;}
                    else r++;
                }
                else if(list[i]=='D'){
                    if(r>0) {r--;list[i]=' ';sum_d--;}
                    else d++;
                }
            }
        }
        if(sum_r==0) return "Dire";
        return "Radiant";
    }
}
